﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI.Selection;

namespace YArchitech.Revit
{
	public class PipeAndFixturesFilter : ISelectionFilter
	{
		public bool AllowElement(Element elem)
		{
			if (elem is Pipe)
			{
				return !YJKRevitTools.isRiserPipe(elem as Pipe);
			}
			if (elem is FamilyInstance)
			{
				FamilyInstance familyInstance = elem as FamilyInstance;
				BuiltInCategory integerValue = elem.Category.Id.IntegerValue;
				if (integerValue == -2001160 && familyInstance.MEPModel.ConnectorManager != null)
				{
					return true;
				}
				if (integerValue == -2008055 && (familyInstance.Symbol.Family.Name.Contains("地漏") || familyInstance.Symbol.Family.Name.Contains("清扫口")))
				{
					return true;
				}
			}
			return false;
		}

		public bool AllowReference(Reference reference, XYZ position)
		{
			return false;
		}
	}
}
